package edu.sctu.wulixia.month6.day20150607;

/**
 * Created by user05 on 2015/6/7.
 */
public class Calculagraph2 implements Runnable{
    Thread thread;
    public boolean flag = true;

    public Calculagraph2(){
        thread = new Thread(this);
    }
    @Override
    public void run() {
        long beginTime = System.currentTimeMillis();
        long time = 0;//过去的时间

        while(flag){
            time = System.currentTimeMillis() - beginTime;
            System.out.println("已过"+(time/1000)+"秒");
            try {
                Thread.sleep(1000);
            }catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    //启动线程
    public void start(){
        thread.start();
    }

    //结束线程
    public void stop() {
        flag = false;
    }
}
